Skip to content

docs: fix two broken examples in transports.md - #3774

Open
Aiudadadadf wants to merge 1 commit into
encode:masterfrom
Aiudadadadf:doc/fix-transports-https-redirect-example
Open

Aiudadadadf wants to merge 1 commit into
encode:masterfrom
Aiudadadadf:doc/fix-transports-https-redirect-example

Conversation

@Aiudadadadf

Copy link
Copy Markdown

Found two broken examples in docs/advanced/transports.md that would confuse anyone trying to run them.

The first is in the "Custom transports" section. It references httpx.Mounts() as a class, which doesn't exist - the correct way to use mounts is passing a dict to Client(mounts=...). The example also had a missing comma between dict entries, and then passed the result in as transport=transport instead of mounts=mounts. Fixed it to use Client(mounts={...}) inline so there's no ambiguity.

The second is in the "Mounting transports" section. The HTTPSRedirectTransport class had handle_request(self, method, url, headers, stream, extensions) returning a tuple (303, headers, stream, extensions) - that's the old low-level transport API from a previous major version. The current BaseTransport.handle_request takes a single Request object and returns a Response. Rewrote it to match, using request.url.copy_with(scheme="https") and httpx.Response(303, ...) the same way the nearby HTTPSRedirect example already does it correctly.

@OKAN-SOFTWARE OKAN-SOFTWARE left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed a Markdown formatting regression in the updated mounts example.

The closing code fence (```) was removed after the httpx.Client(mounts={...}) block.

As a result, the following paragraph beginning with “A useful pattern here is custom transport classes...” is rendered inside the Python code block instead of as normal documentation text.

Could we restore the closing triple-backtick immediately after })?

This should preserve the intended Markdown structure while keeping the corrected transport example.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants